LAGOS Analysis

Loading in data

First download and then specifically grab the locus (or site lat longs)

# #Lagos download script
LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())
## Warning in LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path()): LAGOSNE data for this version already exists on the local machine.
##   Re-download if neccessary using the 'overwrite` argument.'
#Load in lagos
lagos <- lagosne_load()
## Warning in (function (version = NULL, fpath = NA) : LAGOSNE version unspecified,
## loading version: 1.087.3
#Grab the lake centroid info
lake_centers <- lagos$locus

Convert to spatial data

#Look at the column names
names(lake_centers)
##  [1] "lagoslakeid"       "nhdid"             "gnis_name"        
##  [4] "nhd_lat"           "nhd_long"          "lake_area_ha"     
##  [7] "lake_perim_meters" "nhd_fcode"         "nhd_ftype"        
## [10] "iws_zoneid"        "hu4_zoneid"        "hu6_zoneid"       
## [13] "hu8_zoneid"        "hu12_zoneid"       "edu_zoneid"       
## [16] "county_zoneid"     "state_zoneid"      "elevation_m"
#Look at the structure
str(lake_centers)
## 'data.frame':    141265 obs. of  18 variables:
##  $ lagoslakeid      : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ nhdid            : chr  "50524769" "123632625" "50524793" "135695054" ...
##  $ gnis_name        : chr  NA "Benton Pond" NA "Wedge Pond" ...
##  $ nhd_lat          : num  42.5 42.2 42.5 42.5 42.6 ...
##  $ nhd_long         : num  -73.2 -73 -73.2 -71.1 -70.8 ...
##  $ lake_area_ha     : num  114.95 24.87 75.41 9.26 14 ...
##  $ lake_perim_meters: num  9296 2939 5822 1417 2013 ...
##  $ nhd_fcode        : int  43613 39009 43613 39004 39004 39010 39004 39004 39004 39004 ...
##  $ nhd_ftype        : int  436 390 436 390 390 390 390 390 390 390 ...
##  $ iws_zoneid       : chr  "IWS_45400" "IWS_41585" "IWS_44511" "IWS_42712" ...
##  $ hu4_zoneid       : chr  "HU4_12" "HU4_7" "HU4_12" "HU4_10" ...
##  $ hu6_zoneid       : chr  "HU6_15" "HU6_10" "HU6_15" "HU6_11" ...
##  $ hu8_zoneid       : chr  "HU8_49" "HU8_41" "HU8_49" "HU8_35" ...
##  $ hu12_zoneid      : chr  "HU12_16694" "HU12_16612" "HU12_16694" "HU12_16625" ...
##  $ edu_zoneid       : chr  "EDU_75" "EDU_27" "EDU_75" "EDU_58" ...
##  $ county_zoneid    : chr  "County_319" "County_319" "County_319" "County_326" ...
##  $ state_zoneid     : chr  "State_2" "State_2" "State_2" "State_2" ...
##  $ elevation_m      : num  295.86 447.83 295.86 4.26 13.65 ...
#View the full dataset
View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
                          crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100) 

subset_baser <- spatial_lakes[1:100,]

#Dynamic mapviewer
mapview(subset_spatial)

Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)

#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]

#Plotting the first 1000 lakes
minnesota_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

In-Class work

1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

ILIA <- states %>%
  filter(name == 'Illinois' | name == 'Iowa') %>%
  st_transform(2163)

# view outline of Illinois and Iowa
mapview(ILIA)
#Subset lakes based on spatial position
ILIA_lakes <- spatial_lakes[ILIA,] %>% 
    mutate(lake_area_logha = log(lake_area_ha))

#Plotting the first 1000 lakes
ILIA_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa

combined? How does this compare to Minnesota?

length(unique(minnesota_lakes$lagoslakeid))
## [1] 29038
length(unique(ILIA_lakes$lagoslakeid))
## [1] 16466

3) What is the distribution of lake size in Iowa vs. Minnesota?

  • Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)
#create iowa lakes file
iowa <- states %>%
  filter(name == 'Iowa') %>%
  st_transform(2163)

iowa_lakes <- spatial_lakes[iowa,]


#combine ia and mn data, add statename to lake
MNIA_lakes <- rbind(iowa_lakes %>% mutate(state="Iowa"),minnesota_lakes %>% mutate(state="Minnesota")) %>% 
  mutate(lake_area_logha = log(lake_area_ha))

ggplot(MNIA_lakes,aes(lake_area_logha)) +
  geom_histogram() +
  facet_wrap(~state)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

4) Make an interactive plot of lakes in Iowa and Illinois and color them by lake area in hectares

#Plotting the first 1000 lakes
ILIA_lakes %>%
  arrange(-lake_area_logha) %>%
  mapview(.,zcol = 'lake_area_logha')

5) What other data sources might we use to understand how reservoirs and natural lakes vary in size in these three states?

Other data sources could include state records of lakes.

It would also be interesting to see how sizes of waterbodies vary when comparing reservoirs vs. natural lakes, and what percent of lakes are natural between the three states.